import requests
import json
from urllib.parse import urlencode


class ApiBasic:
    url = ""
    headers = {}

    def make_response(self, response, message="请求失败"):
        if response.status_code == 200:
            rep = eval(response.text)
            if rep['ErrNo'] == 101:
                self.get_access_token()
                return rep
            return json.loads(response.text)
        else:
            raise ValueError(message)
